package bjut.core.utils;

import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

/**
 * @Author: zhuzhiming
 * @Date: 2022/4/9 18:17
 */
public final class PropertiesFileUtil {


    public static Properties readPropertiesFile(String file) {

        URL resource = Thread.currentThread().getContextClassLoader().getResource("");

        String zRpcConfigPath = "";

        if (resource != null) {
            zRpcConfigPath = resource.getPath() + file;
        }
        Properties properties = null;
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(zRpcConfigPath), StandardCharsets.UTF_8))) {
            properties = new Properties();
            properties.load(reader);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties;
    }

}
